import time

from pytorch.predict.torchserver import TorchPredict

if __name__ == '__main__':
    torch_predict = TorchPredict()
    total_cost = 0
    times = 1000
    for i in range(times):
        start_time = time.time()
        input = "司机喂装货货主喂喂司机两吨商家货主司机啊两吨货装不了装车扫描的是货主啊两吨将近拉倒司机好好货主货主啊行好好货主好好好"
        result = torch_predict.predict({"sentence": input})
        end_time = time.time()
        cost = end_time - start_time
        total_cost += cost
        print('cost', cost)
    print('avg cost', total_cost / times)
